/**
 * 借款入口文件
 */
define(function (require, exports, module) {

    var UI = require("js/UI");
    var toolTip = require("ui/tip");

    var reg_id=/^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/;
    var reg_phone = /^[1][358][0-9]{9}$/;
    var reg_integer=/^[1-9]\d*$/;

    var $borrowing = $("#borrowing"), $form = $borrowing.find("form")
    var $select = $form.find(".G_select");

    var selectInst1 = UI.dropDownSelect($select.eq(0))
    var selectInst2 = UI.dropDownSelect($select.eq(1))
    UI.datetimepicker($form.find(".dateTime"));


    $form.find("button[type='reset']").unbind("click.reset").bind("click.reset", function () {
        selectInst1.reset();
        selectInst2.reset();
    })



    $form.find("button[type='submit']").unbind("click.sub").bind("click.sub", function () {
        var $required=$form.find(".required input");
        for(var i=0;i<$required.length;i++){
            var $this=$required.eq(i),_val=$this.val(),$par=$this.parent();
            var $obj=$this;
            //更改提示框参照物
            if($this.attr("type")=="hidden"){
                $obj=$this.siblings(".G_ipt");
            }

            var tipInst=new toolTip($obj,"不能为空","right");
            if(!_val){
                tipInst.show()
                return false
            }else{
                if($this.hasClass("number")&&!_val.match(reg_integer)){
                    tipInst.show("请输入正整数");
                    return false
                }

            }
        }
    })













})